#ifndef threading_RecursiveMutex_h
#define threading_RecursiveMutex_h

#ifndef WIN32
# include <pthread.h>
#endif
#include "ThreadConsts.h"
#include "Guard.h"

namespace serika
{
	namespace threading
	{
		class RecursiveMutex
		{
		public:
			RecursiveMutex();
			~RecursiveMutex();
	
			LockState::Enum Acquire(long timeout = -1);		// timeout is in milliseconds
	
			LockState::Enum TryAcquire();
	
			void Release();
	
			typedef Guard<RecursiveMutex> Guard;
		private:
	#ifdef WIN32
			void* mMutex;
	#else
			pthread_mutex_t mMutex;
	#endif
		};
	}
}

#endif
